home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / jabber / JabberBuddies.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  52 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from jabber import JID
  5. from util.observe import observable_dict
  6. from traceback import print_exc
  7. import jabber
  8. import logging
  9. log = logging.getLogger('jabber.buddies')
  10.  
  11. class JabberBuddies(observable_dict):
  12.     
  13.     def __init__(self, protocol):
  14.         observable_dict.__init__(self)
  15.         self.protocol = protocol
  16.  
  17.     
  18.     def __getitem__(self, jid):
  19.         unique = JID(jid).bare()
  20.         
  21.         try:
  22.             return dict.__getitem__(self, unique)
  23.         except KeyError:
  24.             return self.setdefault(unique, jabber.jbuddy(self.protocol, jid))
  25.  
  26.  
  27.     
  28.     def update_presence(self, presence_stanza):
  29.         jid = presence_stanza.get_from()
  30.         log.debug('update_presence for %r', jid)
  31.         
  32.         try:
  33.             buddy = self[jid]
  34.         except Exception:
  35.             e = None
  36.             log.warning('update_presence, "buddy = self[jid]": %r', e)
  37.             print_exc()
  38.             return False
  39.  
  40.         
  41.         try:
  42.             buddy.update_presence(presence_stanza)
  43.         except Exception:
  44.             e = None
  45.             log.warning('update_presence, "buddy.update_presence(presence_stanza)": %r' % e)
  46.             print_exc()
  47.             return False
  48.  
  49.         return True
  50.  
  51.  
  52.